//
//  UIView+InputHandler.m
//  Shuaiche
//
//  Created by zzs on 2018/12/7.
//  Copyright © 2018年 zzs. All rights reserved.
//

#import "UIView+InputHandler.h"
#import <objc/runtime.h>

static const NSString *kInputEmojiUnEnabled = @"inputEmojiUnEnabledKey";
static const NSString *kIsIntOnly = @"intNumberOnlyKey";
static const NSString *kIsFloatOnly = @"foatNumberOnlyKey";
static const NSString *kInputMaxLength = @"inputMaxLength";

@implementation UIView (InputHandler)

- (void)setScEmojiUnEnabled:(BOOL)scEmojiUnEnabled{
      objc_setAssociatedObject(self, (__bridge void*)kInputEmojiUnEnabled, @(scEmojiUnEnabled), OBJC_ASSOCIATION_RETAIN);
}

- (BOOL)scEmojiUnEnabled{
    id value = objc_getAssociatedObject(self, (__bridge void*)kInputEmojiUnEnabled);
    if(!value){
        return NO;
    }else{
        return [value boolValue];
    }
}

- (void)setScIntNumberOnly:(BOOL)scIntNumberOnly{
    objc_setAssociatedObject(self, (__bridge void*)kIsIntOnly, @(scIntNumberOnly), OBJC_ASSOCIATION_RETAIN);
}

- (BOOL)scIntNumberOnly{
    id value = objc_getAssociatedObject(self, (__bridge void*)kIsIntOnly);
    if(!value){
        return NO;
    }else{
        return [value boolValue];
    }
}

- (void)setScFloatNumberOnly:(BOOL)scFloatNumberOnly{
    objc_setAssociatedObject(self, (__bridge void*)kIsFloatOnly, @(scFloatNumberOnly), OBJC_ASSOCIATION_RETAIN);
}

- (BOOL)scFloatNumberOnly{
    id value = objc_getAssociatedObject(self, (__bridge void*)kIsFloatOnly);
    if(!value){
        return NO;
    }else{
        return [value boolValue];
    }
}

- (void)setScMaxLength:(NSInteger)scMaxLength{
    objc_setAssociatedObject(self, (__bridge void*)kInputMaxLength, @(scMaxLength), OBJC_ASSOCIATION_RETAIN);
}

- (NSInteger)scMaxLength{
    id value = objc_getAssociatedObject(self, (__bridge void*)kInputMaxLength);
    if(!value){
        return 0;
    }else{
        return [value integerValue];
    }
}


@end
